﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Supermarket.Dal;

namespace Supermarket.Bll
{
    public static class CompanyManager
    {
        public static List<Company> GetAllCompanies()
        {
            List<Company> companies = CompanyDB.GetAllCompanies();

            return companies;
        }

        public static void Update(int companyId, string companyName)
        {
            if (companyName.Length < 50)
            {
                CompanyDB.Update(companyId, companyName);
            }
        }

        public static void CreateCompany(string companyName)
        {
            if (companyName.Length < 50)
            {
                Company company = new Company();
                company.CompanyName = companyName;
                CompanyDB.CreateCompany(company);
            }
            else
            {
                throw new ArgumentOutOfRangeException("companyName", "Максимална дължина за име: 50 символа!");
            }
        }
    }
}
